import { Modal, ProTable, Table } from "knowdesign";
import "./index.less";

const App = ({ sampleData, sampleVisisbal, setSampleVisisbal }) => {
  console.log(sampleData);
  return (
    <>
      <Modal
        title={`数据表-${
          sampleData?.tableName || ""
        }-20条样例数据`}
        visible={sampleVisisbal}
        onOk={() => {
          setSampleVisisbal(false);
        }}
        centered
        onCancel={() => {
          setSampleVisisbal(false);
        }}
        width={"70vw"}
      >
        {sampleData?.data ? (
          <ProTable
            tableProps={{
              showHeader: false,
              rowKey: "id",
              dataSource: sampleData?.data || [],
              noPagination: true,
              columns: sampleData?.columns || ([] as any),
              lineFillColor: true,
              attrs: {
                // onChange: onTableChange,
                scroll: {
                  scrollToFirstRowOnChange: true,
                  x: true,
                  y: "calc(100vh - 270px)",
                },
              },
            }}
          />
        ) : (
          ""
        )}
      </Modal>
    </>
  );
};

export default App;
